﻿
function StripWebServiceResponse(msg){
    if (msg.hasOwnProperty("d"))
        return msg.d;
    else
        return msg;
}

function CheckIfLoggedIn(){
    LogosoftSharepoint.WebServices.LoginService.CheckIfLoggedIn(CheckIfLoggedInCallback);
}

function CheckIfLoggedInCallback(loginResponse){
    loginResponse = StripWebServiceResponse(loginResponse);
    if(loginResponse.IsLoggedIn){
        $("#LogoutButton").show();
        $("#WelcomeMessage").show();
        $("#LoginContainer").hide();
        $("#WelcomeMessage").html("Witaj " + loginResponse.Name + "!");
    }else{
        $("#LogoutButton").hide();
        $("#WelcomeMessage").hide();
    }
}

function Logout(){
    LogosoftSharepoint.WebServices.LoginService.Logout(LogoutCallback);
}

function LogoutCallback(){
    window.location = "../Default.aspx";
}


